import { useDict } from '@/composables/useDict'
import type { TableColums, FormItemRows } from '@meetjs/element-plus-kit'
import { ATHLETE_DICT } from '@/constants/dictKeys'

const { dicts } = useDict([ATHLETE_DICT.RACE_LEVEL, ATHLETE_DICT.PROJECT, ATHLETE_DICT.LEVEL])

// 表格列配置
export const tableColumns: TableColums[] = [
	{
		prop: 'raceLevelLabel',
		label: '赛事级别',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'raceName',
		label: '赛事名称',
		minWidth: 180,
		align: 'center'
	},
	{
		prop: 'raceGroup',
		label: '比赛组别',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'raceMajorLabel',
		label: '比赛大项',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'raceMinor',
		label: '比赛小项',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'raceTime',
		label: '比赛时间',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'raceRank',
		label: '比赛名次',
		minWidth: 80,
		align: 'center'
	},
	{
		prop: 'raceGrade',
		label: '比赛成绩',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'racePlace',
		label: '比赛地点',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'racePoint',
		label: '参赛状况',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'trainCoach',
		label: '带训教练',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'gradeLevelLabel',
		label: '成绩等级',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'remark',
		label: '备注',
		minWidth: 120,
		align: 'center'
	},
	{
		prop: 'action',
		label: '操作',
		minWidth: 160,
		fixed: 'right',
		align: 'center'
	}
]

// 表单配置 - 自动布局
export const formOptions: FormItemRows[] = [
	{
		type: 'select',
		label: '赛事级别',
		prop: 'raceLevel',
		required: true,
		options: dicts[ATHLETE_DICT.RACE_LEVEL] as unknown as any
	},
	{
		type: 'input',
		label: '赛事名称',
		prop: 'raceName',
		required: true,
		attrs: {
			placeholder: '请输入赛事名称',
			maxlength: 120
		}
	},
	{
		type: 'input',
		label: '比赛组别',
		prop: 'raceGroup',
		required: true,
		attrs: {
			placeholder: '请输入比赛组别',
			maxlength: 50
		}
	},
	{
		type: 'select',
		label: '比赛大项',
		prop: 'raceMajor',
		required: true,
		options: dicts[ATHLETE_DICT.PROJECT] as unknown as any
	},
	{
		type: 'input',
		label: '比赛小项',
		prop: 'raceMinor',
		required: true,
		attrs: {
			placeholder: '请输入比赛小项',
			maxlength: 50
		}
	},
	{
		type: 'date-picker',
		label: '比赛时间',
		prop: 'raceTime',
		required: true,
		attrs: {
			type: 'date',
			placeholder: '请选择比赛时间',
			format: 'YYYY-MM-DD',
			'value-format': 'YYYY-MM-DD'
		}
	},
	{
		type: 'input',
		label: '比赛名次',
		prop: 'raceRank',
		required: true,
		attrs: {
			placeholder: '请输入比赛名次',
			maxlength: 20
		}
	},
	{
		type: 'input',
		label: '比赛成绩',
		prop: 'raceGrade',
		required: true,
		attrs: {
			placeholder: '请输入比赛成绩',
			maxlength: 50
		}
	},
	{
		type: 'input',
		label: '比赛地点',
		prop: 'racePlace',
		required: true,
		attrs: {
			placeholder: '请输入比赛地点',
			maxlength: 120
		}
	},
	{
		type: 'input',
		label: '参赛状况',
		prop: 'racePoint',
		required: true,
		attrs: {
			placeholder: '请输入参赛状况',
			maxlength: 120
		}
	},
	{
		type: 'input',
		label: '带训教练',
		prop: 'trainCoach',
		required: true,
		attrs: {
			placeholder: '请输入带训教练',
			maxlength: 50
		}
	},
	{
		type: 'select',
		label: '成绩等级',
		prop: 'gradeLevel',
		required: true,
		options: dicts[ATHLETE_DICT.LEVEL] as unknown as any,
		attrs: {
			placeholder: '请输入成绩等级',
			maxlength: 50
		}
	},
	{
		type: 'textarea',
		label: '备注',
		prop: 'remark',
		attrs: {
			placeholder: '请输入备注信息',
			rows: 3,
			maxlength: 500,
			'show-word-limit': true
		}
	}
]
